package cn.iocoder.yudao.module.trade.framework;

import cn.iocoder.yudao.framework.datapermission.v1.UniDataPermissionRuleCustomizer;
import cn.iocoder.yudao.module.trade.aftersale.dal.dataobject.AfterSaleDO;
import cn.iocoder.yudao.module.trade.aftersale.dal.dataobject.AfterSaleLogDO;
import cn.iocoder.yudao.module.trade.cart.dal.dataobject.CartDO;
import cn.iocoder.yudao.module.trade.config.dal.dataobject.TradeConfigDO;
import cn.iocoder.yudao.module.trade.delivery.dal.dataobject.DeliveryExpressTemplateChargeDO;
import cn.iocoder.yudao.module.trade.delivery.dal.dataobject.DeliveryExpressTemplateDO;
import cn.iocoder.yudao.module.trade.delivery.dal.dataobject.DeliveryExpressTemplateFreeDO;
import cn.iocoder.yudao.module.trade.delivery.dal.dataobject.DeliveryPickUpStoreDO;
import cn.iocoder.yudao.module.trade.order.dal.dataobject.TradeOrderDO;
import cn.iocoder.yudao.module.trade.order.dal.dataobject.TradeOrderItemDO;
import cn.iocoder.yudao.module.trade.statistics.dal.dataobject.TradeStatisticsDO;
import cn.iocoder.yudao.module.trade.verify.dal.dataobject.TradeVerifyRecordDO;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * permission 组件的 Configuration
 */
@Configuration(proxyBeanMethods = false)
public class TradeDataPermissionConfiguration {

    @Bean
    public UniDataPermissionRuleCustomizer tradeDataPermissionRuleCustomizer() {
        return rule -> {
            // shop 基于店铺的数据权限
            rule.addDataColumn(AfterSaleDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(AfterSaleLogDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(CartDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(TradeConfigDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(DeliveryExpressTemplateChargeDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(DeliveryExpressTemplateDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(DeliveryExpressTemplateFreeDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(DeliveryPickUpStoreDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(TradeOrderDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(TradeOrderItemDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(TradeVerifyRecordDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(TradeStatisticsDO.class, "shop_id"); // WHERE shop_id = ?
        };
    }

}
